/** @format */

import { reactive, effect } from '../lib/reactive.js'
const obj = reactive({ text: 'hello world!', info: '其他信息代表', count: 0 })

let id = null
const logInfo = () => {
  if(id) {
    clearTimeout(id)
    id = null
  }
  id = setTimeout(() => {
    console.log('log info', obj.info)
  }, 0);
}
const updateDocument = () => {
  document.body.innerText = obj.text
}

effect(updateDocument, { scheduler: logInfo })

setTimeout(() => {
  obj.text = 'hello world after 1s'
  obj.text = 'hello world after 1s'
  obj.text = 'hello world after 1s'
  obj.text = 'hello world after 1s'
  obj.text = 'hello world after 1s'
}, 1000)
